package com.link.base.base.buryingpoint.advertising.controller;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

import com.link.base.base.buryingpoint.advertising.model.AdvertisingTracking;
import com.link.base.base.buryingpoint.advertising.service.AdvertisingTrackingService;
import com.link.core.basic.controller.BasicController;
import com.link.core.basic.service.BasicService;
import com.link.core.basic.service.KeyGenerateService;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.HashMap;
import java.util.Map;

/**
 * 广告跟踪-广告跟踪 
 *
 * @author 秦学刚
 * @date 2019/02/26 14:44
 */
@Controller
@RequestMapping("/link/advertisingTracking")
public class AdvertisingTrackingController extends BasicController<AdvertisingTracking> {
 
    @Resource
    private KeyGenerateService keyGenerateService;

    @Resource
    private AdvertisingTrackingService advertisingTrackingService;

    @Override
    public BasicService<AdvertisingTracking> getBasicService() throws Exception {
        return advertisingTrackingService;
    }

    /**
     * 批量更新领取优惠券的微信code
     *
     * @return 更新结果
     * @author KuangRuifeng
     * @date 2018年12月4日
     */
    @RequestMapping(value = "/advertInvalid")
    @ResponseBody
    public Map<String, Object> advertInvalid(@RequestBody AdvertisingTracking advertisingTracking, HttpSession session,
                                          HttpServletRequest request, HttpServletResponse response) {
        Map<String, Object> result = new HashMap<String, Object>(2);
        try {
            advertisingTrackingService.advertInvalid(advertisingTracking);
            result.put("success", true);
        } catch (Exception e) {
            result.put("success", false);
            result.put("result", e.getMessage());
        }
        return result;
    }
}
